package com.sun.jdk.stream;

import java.util.*;
import java.util.stream.Stream;

/**
 * Stream流的两种获取方式
 */
public class StreamTest03 {
    public static void main(String[] args) {
        
        // 通过Collection接口中的默认方法
        List<String> list = new ArrayList<>();
        Stream<String> stream = list.stream();
        
        Set<String> set = new HashSet<>();
        Stream<String> stream1 = set.stream();

        Vector<String> vector = new Vector<>();
        Stream<String> stream2 = vector.stream();
        
        // map集合无法直接获取stream，可以通过以下方式获取
        Map<String,Object> map = new HashMap<>();
        Set<String> keySet = map.keySet();
        Stream<String> stream3 = keySet.stream();

        Collection<Object> values = map.values();
        Stream<Object> stream4 = values.stream();

        Set<Map.Entry<String, Object>> entries = map.entrySet();
        Stream<Map.Entry<String, Object>> stream5 = entries.stream();
        
    }
}
